Tweak-based string encryption

ABSTRACT

A technique includes performing element-by-element encryption of a segment of the plaintext string to provide a segment of an encrypted string. Performing the element-by-element encryption includes, for a given string element of the segment of the plaintext string, encrypting the given string element to provide a given string element of the segment of the encrypted string; and tweaking the encryption of the given string element based on a selector that includes multiple string elements of the encrypted string. The technique may include searching an encrypted database based on the encrypted string.

BACKGROUND

For purposes of protecting sensitive data (data representing socialsecurity numbers, salaries, account information, and so forth) that isstored in a database from unauthorized access, the data may beencrypted. For example, the database may be a relational database thatcontains tables; and various aspects of the tables may be encrypted,such as schema keys and/or data fields of the tables. Encrypting thedata in the database, however, may impose constraints ondatabase-related functions. For example, it may be challenging due tothe encryption to search the database for certain strings (a particularemployee name, information pertaining to a particular department, and soforth).

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of a database environment according to anexample implementation.

FIG. 2 is an illustration of format preserving encryption (FPE) of astring using element-by-element encryption and encryption tweakingaccording to an example implementation.

FIG. 3 is a flow diagram depicting a tweak-based encryption technique togenerate an encrypted string prefix according to an exampleimplementation.

FIG. 4 is an illustration of FPE of a string using multipleelement-by-multiple element encryption, element-by-element encryption,and encryption tweaking according to an example implementation.

FIG. 5 is an illustration of FPE of a string using multipleelement-by-multiple element encryption, element-by-element encryption,encryption tweaking, and keys associated with a key chain according toan example implementation.

FIG. 6 is a schematic diagram of an apparatus to provide an encryptedprefix according to an example implementation.

FIG. 7 is an illustration of a non-transitory computer-readable storagemedium storing instructions that, when executed by a machine, cause themachine to generate an encrypted string prefix according to an exampleimplementation.

DETAILED DESCRIPTION

The data that is stored in a database may be encrypted for purposes ofprotecting confidential information from unauthorized access. Forexample, the database may be a relational database that contains tables,and the data fields of records (rows, for example) of the tables may beencrypted. Due to the encryption, it may be challenging to search for aparticular string or string prefix contained in the database. In thiscontext, a “string” refers to an ordered sequence, or one dimensionalarray, of elements (characters, binary values, integers, and so forth).For example, “Stephanie” is a string of nine characters. A “prefix”(also called a “prefix string” herein), in general, is also a string andmay refer to the initial part, or segment, of a larger string. As such,a prefix is a subgroup of elements of a larger string, beginning withelement number one of the larger string. As examples, “Step,” “Ste” and“Steph” are prefixes of the string “Stephanie.”

An authorized database user may search a database to, for example,retrieve records pertaining to a certain employee name (“Stephanie,” forexample). For this purpose, the user may formulate and submit a query toretrieve records (rows, for example) from the database pertaining toemployee names containing the name “Stephanie.” Alternatively, toperform a more inclusive search, the database user may use a shortersegment, or prefix, of “Stephanie,” such as “step” (where for thefollowing examples, it is assumed the search is case invariant). In thisregard, the user may first submit a query using “step” to retrieve alist of names that include either “step” either in the first fourcharacters of the entire name or in other parts of the field. The usermay then use this list to find the specific row or rows in a table withnames containing “Stephanie” and variants thereof.

The string “Stephanie” and the prefix “step,” used in the examples aboveare examples of plaintext. In this context, “plaintext” refers toinformation that is unencrypted. The plaintext data may be encrypted toproduce encrypted data, or ciphertext; and the ciphertext may bedecrypted in a reversible process to produce the plaintext data. Forexample, a plaintext character string refers to the plain, or ordinary,meaning of the string. For an encrypted database, such as a database inwhich the data fields are encrypted, searching for strings and prefixesmay be relatively more challenging. Searching for the encrypted versionof “Stephanie” or “step” may return relatively few, if any, results. Inthis manner, depending on the encryption used, a pair of ciphertextstrings may be entirely different, although the corresponding plaintextstrings may slightly differ and may contain similar substrings.

One solution to search an encrypted database is to decrypt all of thedata fields of a particular table or tables before doing a search on thetable(s) using a given prefix. Although such an approach may beadvantageous for relatively small tables, the approach may not bepractical for relatively large tables that may have, for example,millions of records (rows). Another solution to search an encrypteddatabase may be to encrypt the entire search string (corresponding to astring size of the data field) and search for data fields containingthis encrypted string. However, this approach does not allow a user toperform partial string, or prefix, searches.

In accordance with example implementations that are described herein,the data fields of a database are encrypted using format preservingencryption (FPE). In this context, FPE refers to a type of encryption inwhich the format of the plaintext data is the same as the format of theencrypted data. For example, for a string, the FPE preserves the formatof a plaintext string (or plaintext prefix) so that the plaintext string(or plaintext prefix) has the same number of characters as thecorresponding ciphertext string (or prefix).

In accordance with example implementations, a plaintext prefix may beencrypted using FPE to generate a corresponding ciphertext prefix, andthe ciphertext prefix may then be used to search for records in theencrypted database. Thus, users may be able to search a table of theencrypted database using a partial string, or prefix, starting from abeginning character or characters (as an example) of a particularstring. For the example given above, a user may search for the prefix“step” of the string “Stephanie” using an FPE-based encrypted prefix.

Referring to FIG. 1, in accordance with example implementations, adatabase environment 100 includes a database management system (DBMS)130, which includes a prefix preserving cryptography engine 132. Inaccordance with example implementations, the cryptography engine isconstructed to generate FPE-based encrypted prefixes (also referred toas “ciphertext prefixes” herein) for searches 140 that are performed onan encrypted database 150. In this manner, the database 150 may be, forexample, a relational database, which contains tables 154, and records156 (rows, for example) of the tables 154 may include encrypted datafields 158.

More specifically, the cryptography engine 132 may, for example,generate a ciphertext prefix in response to a query 114 that may besubmitted by a database user (a user of a computer 110, for thisexample). In this manner, the query 114 may contain one or multipleplaintext string prefixes 116, or strings, to be searched on thedatabase 150; and the cryptography engine 132 may generate one ormultiple corresponding ciphertext prefixes to search for records 156 ofthe database 150 that contain the ciphertext prefixes. As a result ofthis search, the cryptography engine 132 may decrypt the records 156retrieved due to the search, and the DBMS 130 may provide one ormultiple corresponding plaintext records 144 back to the users of thecomputer 110. The encryption and decryption by the cryptography engine132 may involve using keys 162 that may be provided by a key server 160,as further described herein.

It is noted that the database environment 100 is one out of manypossible architectures that may employ FPE-based prefix encryption, asdescribed herein. Other architectures are contemplated and are withinthe scope of the appended claims. For example, in accordance withfurther example implementations, the cryptography engine 132 may be partof the computer 110, and the computer 110 may correspondingly useencrypted string prefixes to access the database 150.

For the specific example of FIG. 1, the DBMS 130 includes one ormultiple actual, physical machines that include actual hardware, such asone or multiple processors 134 (one or multiple central processing units(CPUs), one or multiple CPU cores, and so forth) and a memory 136. TheDBMS 130 may include components (server blades, for example) disposed onthe same rack or on different racks. Moreover, the DBMS 130 may includecomponents that may be disposed at a single geographical location or maybe disposed at multiple geographical locations. The memory is anon-transitory storage media and may be formed from semiconductorstorage devices, non-volatile memory devices, volatile memory devices,phase change memory devices, memristors, one or more of the foregoingmemory technologies, other memory technologies, and so forth.

In accordance with example implementations, the processors 134 mayexecute machine executable instructions 137 (or “software”), which maybe stored in the memory 136. In this manner, in accordance with someimplementations, the cryptography engine 132 may be formed from a set ofmachine executable instructions 137 that are executed by one or multipleprocessors 134. The memory 136 may also store data 139, such as datathat represents unencrypted, or plaintext data; encrypted, or ciphertextdata; keys; variables; data structures; preliminary, intermediate orfinal processing results that are described herein; and so forth.

In accordance with some implementations, the cryptography engine 132 maybe formed from a group, or library, of application programminginterfaces (APIs), which provide prefix encryption and decryptionfunctions. For example, in accordance with some implementations, thecryptography engine 132 may provide the following three APIs:

Encrypt(K, S)->C;

Decrypt(K, C)->S, and

EncryptPrefix(K, P)->EP,

where “K” represents a key; “S” represents a plaintext string; “C”represents a ciphertext string; “P” represents a plaintext prefix; and“EP” represents an encrypted, or ciphertext, prefix.

The encrypted prefix EP allows matching in the encrypted domain. Asexamples, the above three APIs may perform the following functions withthe string “EXAMPLE” and prefix “EXA”:

Encrypt(K, “EXAMPLE”)->“QRRMOFY”

Decrypt(K, “QRRMOFY”)->“EXAMPLE”

EncryptPrefix(K, “EXA”)->“QRR”

It is noted that, as illustrated above, in accordance with exampleimplementations, the encryption preserves the prefix. In this manner,“EXAMPLE” encrypts to “QRRMOFY,” and the first three characters of“EXAMPLE” encrypts to the first three letters of “QRRMOFY,” or “QRR.”

In accordance with further example implementations, the cryptographyengine 132 may not include a library, such as a library containing theabove-mentioned APIs. Moreover, in accordance with yet further exampleimplementations, the cryptography engine 132 may be hardware-based,which does not involve processor-based machine executable instructionexecution. For example, in accordance with further implementations, thecryptography engine 132 may be a field programmable gate array (FPGA),an application specific integrated circuit (ASIC), and so forth.

Regardless of its particular form, the cryptography engine 132, inaccordance with example implementations, is constructed to encrypt aplaintext string (or any portion thereof) using a tweak-based formatpreserving encryption and decrypt a ciphertext string using acorresponding tweak-based format preserving decryption. Moreover, asdescribed herein, in accordance with example implementations, theencryption/decryption may include an element-by-elementencryption/decryption; may include a multiple element-by-elementencryption/decryption; and may involve the use of a key chain, orladder.

FIG. 2 illustrates an element-by-element prefix encryption 200 that maybe used by the cryptography engine 132 according to an exampleimplementation. For this example, a plaintext string 210, here,“EXAMPLE,” may be encrypted to provide a corresponding ciphertext string250, here, “QRRMOFY.” Moreover, the element-by-element encryption 200may be used to encrypt any initial segment, or prefix, of the plaintextstring 210, such as example plaintext prefix “EXAMP” 211, whichcorresponds to ciphertext prefix “QRRMO” 251. In this manner, a databaseuser may perform a task in which the database 150 (FIG. 1) is searchedusing the prefix 211. As depicted in FIG. 2, the ciphertext prefix 251has the same number of characters (i.e., the same prefix length) as thecorresponding plaintext prefix 211. In FIG. 2, the prefix length isfive, although the prefix length may be longer or shorter than five.

In accordance with example implementations, each element of theplaintext string 210 may be encrypted by applying a correspondingencryption algorithm, or cipher 220 (an Advanced Encryption Standard(AES) block cipher having a 256 bit block size, as an example), to theelement. In this manner, FIG. 2 depicts the application of ciphers220-1, 220-2 . . . 220-7 to corresponding elements of the plaintextstring 210. In general, the elements of the ciphertext string 250 aregenerated in an ordered sequence, corresponding to the ordered sequenceof the elements of the plaintext string 210. In this manner, beginningwith the first element (“E”) of the plaintext string 210, the cipher220-1 is applied to generate the first element (“Q”) of the ciphertextstring 250; next, the cipher 220-2 is applied to the second element(“X”) of the plaintext string 210 to generate the second element (“R”)of the ciphertext string 250; subsequently, the cipher 220-3 is appliedto the third element (“A”) of the plaintext string 210 to generate thethird element (“R”) of the ciphertext string 250; and so forth. Inaccordance with example implementations, although the same basic cipher220 may be applied to each plaintext string element, for a givenplaintext string element, the cipher 220 that is applied to the elementis altered, or “tweaked,” based on the portion of the ciphertext string250 that has already been generated.

In the context of this application, the “tweaking” of a cipher refers tothe modification of the cipher based on a tweak input, or selector. Forexample, in accordance with some implementations, the cipher 220 may bea block cipher; and a key is used as an index to select a certainpermutation (of a plurality of potential permutations) of the blockcipher (used for encryption or decryption). The tweak input, orselector, may be an additional index that is used to select thepermutation of the block cipher. In other words, in accordance withexample implementations, the combination of the key and the tweak forman index that selects the permutation for the block cipher. Unlike thekey, the tweak may not be secret. Instead, as described herein, thetweak selector for a given cipher 220 may be formed from one or multiplecharacters of the ciphertext string 250.

More specifically, in accordance with example implementations, the tweakinput, or selector, for a given cipher 220 is the string of element(s)of the part of the ciphertext string 250 that has already beengenerated. For the application of the cipher 220-1 to the first elementof the plaintext string 210, there are no previously generatedciphertext elements. Therefore, in accordance with exampleimplementations, no tweaking occurs in the application of the cipher220-1. In other words, the encrypted character “Q” is generated based ona key, the input “E” and the cipher 220-1. The tweaking begins with thegeneration of the second element of the ciphertext string 250, inaccordance with example implementations. In this manner, the secondelement (“X”) of the plaintext string 210, is encrypted by applying thecipher 220-2 and tweaking the cipher 220-2 using a tweaking selectorformed from the portion of the ciphertext string 250, which had beengenerated (here, “Q”). As such, the cipher 220-2 is tweaked by “Q,” andin conjunction with a key, a permutation of the cipher 220-2 is selectedto encrypt “X” to produce a corresponding element (“R”) of theciphertext string 250.

In a similar manner, the third element (“A”) of the plaintext string210, “A,” is encrypted by a cipher 220-3 that is tweaked by “QR.” Theencryption of the plaintext string 210 may continue in a similarelement-by-element fashion, such that, for the last element (“E”) of theplaintext string 210, the “E” is encrypted by a cipher 220-7 that istweaked by “QRRMOF” to produce the last element (“Y”) of the ciphertextstring 250.

In accordance with example implementations, the element-by-elementprefix encryption 200 may performed by a processor 134 (FIG. 1)repeatedly executing a set of machine executable instructions for eachplaintext character to be encrypted. In this manner, each time theprocessor 134 executes the set of instructions, the processor 134 may,for each plaintext element to be encrypted, tweak a cipher based on thealready (if any) generated elements of the ciphertext prefix, andencrypt the element using the tweaked cipher.

It is noted that although FIG. 2 depicts encryption, anelement-by-element decryption may be applied in a similar manner togenerate an arbitrary length plaintext string from a ciphertext stringof the same length. The decryption proceeds in the opposite directionalong the string relative to the encryption. For example, to decrypt theciphertext prefix 251, the last element (“O”) of the ciphertext prefix251, is decrypted by tweaking a cipher based on the first four elements(“QRRM”) of the prefix 251 and applying the tweaked cipher to generatethe last element (“P”) of the prefix 211); the fourth element (“M”) ofthe ciphertext prefix 251, is decrypted by tweaking a cipher based onthe first three elements (“QRR”) of the prefix 251 and applying thetweaked cipher to generate the fourth element (“M”) of the prefix 211;and so forth.

Thus, referring to FIG. 3, in accordance with example implementations, atechnique 300 may be used to encrypt a plaintext string. The technique300 includes, pursuant to block 304, performing element-by-elementencryption of a segment of the plaintext string to provide a segment ofan encrypted string. Performing the element-by-element encryptionincludes, for a given string element of the segment of the plaintextstring, encrypting the given string element to provide a given stringelement of the segment of the encrypted string; and tweaking theencryption of the given string element based on a selector that includesmultiple string elements of the encrypted string. The technique includessearching an encrypted database based on the encrypted string, pursuantto block 308.

An encryption, such as the encryption 200 of FIG. 2, which encrypts thefirst element of a plaintext string to the same ciphertext element value(the same character for a character string, for example), regardless ofthe other elements of the plaintext string, may be susceptible to asecurity attack called a “dictionary attack.” In this manner, knowledgethat the first element of a plaintext string encrypts to a givenciphertext element value may be used to search and sort encrypted datawith some degree of granularity. For example, if the first plaintextelement of a string is “E” and the corresponding first ciphertextelement is “Q,” then an attacker may glean that all ciphertexts startingwith “Q” actually start with the plaintext “E.”

Referring to FIG. 4, to inhibit such a dictionary attack, in accordancewith further example implementations, the cryptography engine 132(FIG. 1) may apply an FPE-based encryption 400, in which a multipleelement-by-multiple element encryption 460 is applied to the lower orderelements of the plaintext string 210 (elements one to three for example)and element-by-element encryption 464 is applied to the higher orderelements of the plaintext string 210 (elements four and higher, forexample).

More specifically, FIG. 4 depicts encryption of the plaintext string 210to generate a ciphertext string 410. A segment of the plaintext string210, such as example plaintext prefix 211, may be encrypted to produce acorresponding segment of the ciphertext string 410, such as exampleciphertext prefix 411. For the multiple element-by-multiple elementencryption 460, the first three elements (“EXA”) of the plaintext string210 are encrypted by an FPE-based multiple element cipher 420 to providethree corresponding elements (“XDA”) of the ciphertext string 410. As anexample, the cipher 420 may be a block cipher (a 65,536 bit blockcipher, for example). Therefore, by grouping multiple elements together,a dictionary attack may be avoided in that, for example, the firstplaintext element “E” does not necessarily encrypt to the first element“X” of the ciphertext string 410, but rather, the value for the firstciphertext element depends on the first three plaintext elements.

The remaining elements (elements four and above) of the plaintext string210, in accordance with example implementations, are encrypted using theelement-by-element encryption 464, as described above. In this regard,FIG. 4 depicts ciphers 420 (ciphers 424-1, 424-2, 424-3, and 424-4),which are tweaked by the corresponding parts of the ciphertext string410 already generated. For example, “M” is provided to cipher 424-1,which is tweaked based on “XDA” to provide a corresponding element “Q.”

It is noted that although FIG. 4 depicts encryption, the decryption maybe applied in a similar manner to generate an arbitrary length plaintextstring from a ciphertext string of the same length. The decryptionproceeds in the opposite direction along the string relative to theencryption.

In accordance with example implementations, the cryptography engine 132(FIG. 1) may place a limit on the length of the prefix to be searched.For example, referring to FIG. 4, the length may be limited to five,thereby limiting the ciphertext prefix string 211 to “XDAQM” and therebynot allowing a search of prefixes greater than five elements).

In accordance with some implementations, the length of the prefix stringmay be regulated using a key chain, or ladder. In this manner, referringto FIG. 1, the cryptography engine 132 may receive a key 162 (from a keyserver 160, for example) and apply a hash function to the key 162 togenerate a chain, or ladder, of keys to be used in the prefixencryption. In this manner, a ladder of keys may be created using a hashfunction as follows:

K _(L-1) =H(K),K _(L-2) =H(K _(L-1)),K _(L-3) =H(K _(L-2)), . . . ,K ₀=H(K ₁),

where “H( )” represents the hash function; “K” represents the keyreceived from the key server; and “K_(L-1),” “K_(L-2),” “K_(L-3),” . . .“K₁,” and “K₀” represent the keys that are generated by applying thehash function H( ) and are provided to corresponding ciphers; and “L”represents the maximum prefix length. By providing the key K_(x), X+1elements of the prefix may be decrypted, but no more keys may bederived. For example, the keys K_(X−1), K_(X−2), K_(X−3), etc. may begenerated by hashing, starting with applying the hash function to theK_(x), but the key K_(X+1) may not be recovered.

The above-described key chain may be used in conjunction with an FPEencryption 500 illustrated in FIG. 5, in accordance with exampleimplementations. In general, the encryption 500 is similar to theencryption 400 of FIG. 4, with like reference numerals being used todenote similar components. In FIG. 5, however, the encryption 500 useskeys (such as the five depicted keys K₆, K₅, K₄, K₂ and K₁) that arederived from a key chain. In general, FIG. 5 depicts encryption of theplaintext string 210 to generate a ciphertext string 510. A segment ofthe plaintext string 210, such as example plaintext prefix 211, may beencrypted to produce a corresponding segment of the ciphertext string510, such as example ciphertext prefix 511. As described below, the keychain may be used to control the length of the plaintext 211 prefix thatmay be encrypted and used.

The multiple element-by-multiple element cipher 420 encrypts based on akey K₆, and the tweakable ciphers 424-1, 424-2, 424-3 and 424-4 encryptbased on keys K₅, K₄, K₂ and K₁, respectively. As depicted in FIG. 5,when multiple element-by-multiple element encryption is used to encryptthe initial three elements of the prefix, the maximum length of theprefix is controlled by a number of keys available from the key chain,which is two less than the maximum length (to account for the elementgrouping); and the key K₃ (or another key) may not be used. Thus, asexamples, for a maximum prefix length of seven, five keys are used, asdepicted in FIG. 5; for a maximum prefix length of five, three keys(keys K₄, K₂ and K₁) are used; and so forth.

It is noted that although FIG. 5 depicts encryption, the decryption maybe applied in a similar manner to generate an arbitrary length plaintextstring from a ciphertext string of the same length. The decryptionproceeds in the opposite direction along the string relative to theencryption.

The key chain may be used for the encryption 200 of FIG. 2, inaccordance with further example implementations. For theseimplementations, the number of keys available from the key chaincontrols the maximum prefix length. As an example, for a maximum prefixlength of five, keys K₄, K₃, K₂ and K₁ may be used by the ciphers 220-1,220-2, 220-3, 220-4 and 220-5, respectively.

Referring to FIG. 6, in accordance with example implementations, anapparatus 600 includes a processor 604 and a memory 608. The memory 608stores instructions 612 that, when executed by the processor 604, causethe processor 604 to apply a multiple element cipher to first elementsof a plaintext string to generate first elements of a ciphertext prefix;apply a single element cipher to a second element of the plaintextstring to generate a second element of the ciphertext prefix; and tweakthe application of the single element cipher based on a selector thatincludes the first elements of the ciphertext prefix.

More specifically, referring to FIG. 7, in accordance with exampleimplementations, a non-transitory machine readable storage medium 700stores instructions 702 that, when executed by a machine, cause themachine to receive a query that is directed to a database that includesencrypted data. The query includes a decrypted prefix that includes afirst plurality of elements. The instructions 702, when executed by themachine, cause the machine to apply a first cipher to a first part ofthe decrypted prefix to generate a first part of an encrypted prefix,where the first part of the decrypted prefix includes multiple elements;and apply a second cipher to a given element of the decrypted prefixbased on a key and a tweak input that includes the first part of theencrypted prefix to generate a given element of the encrypted prefix.The instructions 702, when executed by the machine, cause the machine toprocess the query based on the encrypted prefix.

While the present disclosure has been described with respect to alimited number of implementations, those skilled in the art, having thebenefit of this disclosure, will appreciate numerous modifications andvariations therefrom. It is intended that the appended claims cover allsuch modifications and variations

What is claimed is:
 1. A method comprising: for a plaintext stringcomprising a plurality of string elements, performing element-by-elementencryption of a segment of the plaintext string to provide a segment ofan encrypted string comprising a plurality of string elements, whereinperforming the element-by-element encryption comprises, for a givenstring element of the segment of the plaintext string: encrypting thegiven string element to provide a given string element of the segment ofthe encrypted string; and tweaking the encryption of the given stringelement based on a selector comprising multiple string elements of theplurality of elements of the encrypted string; and searching anencrypted database based on the encrypted string.
 2. The method of claim1, further comprising: performing multiple element by multiple elementencryption of another segment of the plaintext string to provide anothersegment of the encrypted string, wherein the selector comprises theanother segment.
 3. The method of claim 2, wherein: performing theelement-by-element encryption comprises repeatedly applying a firstblock cipher associated with a first block size; and performing themultiple element by multiple element encryption comprises applying asecond block cipher associated with a second block size larger than thefirst block size.
 4. The method of claim 1, further comprisinggenerating a chain of keys based on a hash and another key, whereinperforming the element-by-element encryption comprises performing theelement-by-element encryption based on the chain of keys.
 5. The methodof claim 1, wherein: encrypting the given string element comprisesapplying a block cipher; and tweaking the encryption comprises selectinga permutation of the block cipher based on a key and the selector. 6.The method of claim 1, wherein the selector comprises a stringcomprising the multiple string elements.
 7. The method of claim 1,wherein: encrypting the given string element comprises applying a blockcipher; and performing the element-by-element encryption furthercomprises: encrypting another element of the segment of the plaintextstring to provide another element of the encrypted string; and tweakingthe encryption of the another element based on a selector comprising thegiven element and the multiple elements of the encrypted string.
 8. Themethod of claim 1, wherein the plurality of elements of the plaintextstring represent characters.
 9. An apparatus comprising: a processor;and a memory to store instructions that, when executed by the processor,cause the processor to: apply a multiple element cipher to firstelements of a plurality of elements of a plaintext string to generatefirst elements of a ciphertext prefix; apply a single element cipher toa second element of the plurality of elements of the plaintext string togenerate a second element of the ciphertext prefix; and tweak theapplication of the single element cipher based on a selector comprisingthe first elements of the ciphertext prefix.
 10. The apparatus of claim9, wherein: the instructions, when executed by the processor, cause theprocessor to repeatedly apply the single element cipher to an outputstring corresponding to the ciphertext prefix as the ciphertext prefixis being generated; the output string has a length that increases witheach application of the single element cipher; and selector furthercomprises the output string.
 11. The apparatus of claim 9, wherein theinstructions, when executed by the processor, cause the processor toapply format preserving encryption to the plaintext string prefix togenerate the ciphertext string prefix.
 12. The apparatus of claim 9,wherein the instructions, when executed by the processor, cause theprocessor to query a database based on the ciphertext prefix.
 13. Theapparatus of claim 9, wherein the instructions, when executed by theprocessor, cause the processor to limit a length of the ciphertextprefix.
 14. The apparatus of claim 9, wherein the instructions, whenexecuted by the processor, cause the processor to: apply a first key ofa plurality of keys in the application of the multiple element cipher;and apply a second key of the plurality of keys other than the first keyin the application of the single element cipher.
 15. The apparatus ofclaim 14, wherein the instructions, when executed by the processor,cause the processor to receive a key from a key server and apply a hashfunction to generate the plurality of keys from the received key.
 16. Anon-transitory machine readable storage medium to store instructionsthat, when executed by a machine, cause the machine to: receive a querydirected to a database comprising encrypted data, wherein the querycomprises a decrypted prefix comprising a first plurality of elements;apply a first cipher to a first part of the decrypted prefix to generatea first part of an encrypted prefix, wherein the first part of thedecrypted prefix comprises multiple elements of the first plurality ofelements, the encrypted prefix comprises a second plurality of elements,and the second part comprises multiple elements of the second pluralityof elements; apply a second cipher to a given element of the firstplurality of elements based on a key and a tweak input comprising thefirst part of the encrypted prefix to generate a given element of thesecond plurality of elements; and process the query based on theencrypted prefix.
 17. The non-transitory machine readable storage mediumof claim 16, wherein the instructions, when executed by the machine,cause the machine to apply the second cipher to another element of thefirst plurality of elements based on a key and a tweak input comprisingthe first part of the encrypted prefix and the given element of thesecond plurality of elements to generate another element of the secondplurality of elements.
 18. The non-transitory machine readable storagemedium of claim 16, wherein the instructions, when executed by themachine, cause the machine to: associate a first key with the firstcipher; associate a second key different from the first key with thesecond cipher.
 19. The non-transitory machine readable storage medium ofclaim 16, wherein the instructions, when executed by the machine, causethe machine to: receive a key; generate the second key based on thehash; and generate the first key based on the hash and the second key.20. The non-transitory machine readable storage medium of claim 16,wherein the first cipher comprises a first block cipher associated witha first block size, and the second cipher comprises a second blockcipher associated with a second block size smaller than the first blocksize.